public class Point1969 {
    public static void main(String[] args) {

        System.out.println(minNonZeroProduct(31));
    }
    /*求解*/
    public static int minNonZeroProduct(int p){
        long mod = 1000000000L;
        if(p == 1)
            return 1;
        long mod1 = mod + 7;
        long mod2 = mod + 6;
        long x = fastPow(2, p, mod1) - 1;
        long y = ( fastPow(2, p-1, mod2) + mod2 - 1) % mod2;
        long res = x * fastPow(x-1, y, mod1) % mod1;
        return (int) res;
    }

    /*快速幂*/
    public static long fastPow(long x, long n, long mod){
        long result = 1L;
        x %= mod;
        while (n > 0) {
            if ((n & 1) == 1) {
                result = (result * x) % mod;
            }
            x = (x * x) % mod;
            n >>= 1;
        }
        return result;
    }
}
